//添加全局配置文件
const path = require('path');
const webpack = require('webpack')
// 获取当前的时间戳
let timeStamp = new Date().getTime();
module.exports = {
	//关闭esList语法检测功能
	lintOnSave: false,
	//开发服务器相关配置
	devServer: {
		// https: true,
		overlay: {
			warnings: false,
			errors: false
		},
		//配置静态资源目录
		contentBase: path.join(__dirname, 'public'),
		//设置开发服务器的端口号
		port: 8848,
		hot: true, //自动保存
		open: true, //自动启动
		// proxy: {
		// 	//名字可以自定义，这里我用的是api
		// 	'/api': {
		// 		target: 'http://www.smheee.com:8093/files/dev', //设置你调用的接口域名和端口号 别忘了加http
		// 		changeOrigin: true, //这里设置是否跨域
		// 		ws: true,
		// 		pathRewrite: {
		// 			'^/api': ''
		// 		}
		// 	}
		// }
	},
	filenameHashing: false, // 打包的时候不使用hash值.因为我们有时间戳来确定项目的唯一性了.
	//配置webpack相关
	configureWebpack: {
		plugins: [
			new webpack.ProvidePlugin({
				$: "jquery",

				jQuery: "jquery",
				"windows.jQuery": "jquery"
			})
		],
		//解析
		resolve: {
			//配置路径别名
			alias: {
				'@v': path.resolve(__dirname, 'src/page/'),
				'@cache': path.resolve(__dirname, 'src/cache/'),
				'@assets': path.resolve(__dirname, 'src/assets/'),
				'@style': path.resolve(__dirname, 'src/style/'),
				"@config": path.resolve(__dirname, 'src/config/'),
				"@c": path.resolve(__dirname, 'src/components/'),
				"@m": path.resolve(__dirname, 'src/mixins/')
			}
		},
		output: {
			filename: `js/js[name].${timeStamp}.js`,
			chunkFilename: `js/chunk.[id].${timeStamp}.js`,
		}
	},

	// px转rem配置
	lintOnSave: true,
	css: {
		loaderOptions: {
			postcss: {
				plugins: [
					require('postcss-plugin-px2rem')({
						rootValue: 54,
						exclude: /(node_module)/,
					})
				]
			}
		},
		extract: { // 打包后css文件名称添加时间戳
			filename: `css/[name].${timeStamp}.css`,
			chunkFilename: `css/chunk.[id].${timeStamp}.css`,
		}
	}
}
